package com.msb.dongbao.portal.web.controller.studyCaptcha;


import com.baomidou.kaptcha.Kaptcha;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/kaptcha")
public class KCaptchaController {

    @Autowired
    private Kaptcha kaptcha;

    @GetMapping("/generator")
    public void generatorCode(HttpServletRequest request) {
        System.out.println(request.getSession().getId());
        kaptcha.render();

    }


    @PostMapping("/verify")
    public String verify(@RequestParam String code) {
        System.out.println("code=" + code);
        Boolean aBoolean = kaptcha.validate(code);
        if (aBoolean) {
            return "通过";
        }
        return "不通过";
    }
}
